//
//  NSDictionary+JSON.m
//  SalesStrategy
//
//  Created by Ralf on 1/6/15.
//  Copyright (c) 2015 com.next. All rights reserved.
//

#import "NSMutableDictionary+JSON.h"

@implementation NSMutableDictionary (JSON)

- (NSString *)toJSONString
{
    NSError *error;
    NSData  *jsonData = [NSJSONSerialization dataWithJSONObject:self options:NSJSONWritingPrettyPrinted error:&error];

    if (!jsonData)
    {
        return nil;
    }
    else
    {
        return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    }
}

- (NSData *)toJSONData
{
    NSError *error;
    NSData  *jsonData = [NSJSONSerialization dataWithJSONObject:self options:NSJSONWritingPrettyPrinted error:&error];

    return jsonData;
}

@end
